package dataLayer;


import dataLayer.dataAccessObjects.sqlite.DataLayerSqlite;
import dataLayer.dataAccessObjects.xml.DataLayerXml;
import dataLayer.settings.SettingsManager;

public class DataLayerManager {
	private static DataLayerManager instance;
	private IDataLayer dataLayer;
	private static SettingsManager settings ;
	private DataLayerManager(){
		settings = SettingsManager.getInstance();
	}
	
	/**
	 * Creates Datalayer for DaoClass of XML or SQLite 
	 * @return datalayer
	 */
	public IDataLayer getDataLayer() {
		if(settings.getPersistenceType() == "SQLite"){
			return dataLayer = new DataLayerSqlite();
		}
		else{
			return dataLayer = new DataLayerXml();
		}
	}

	/**
	 * Erzeugt / returns instance od DataLayermanager
	 * @return
	 */
	static public DataLayerManager getInstance() {
		if(instance == null)
		{
			instance = new DataLayerManager();
			
		}
		return instance;
	}
}
